﻿
use ASIVeste

go

/********************************************************************************************
*****
*****
*********************************************************************************************/


if(OBJECT_ID('addProduct') is not null)
	DROP PROCEDURE addProduct
	
go

create procedure addProduct(@minStock int, @supplier int, @type varchar(20), @stock int)
as

	insert into Product(minStock, supplier, type, stock, ordered) Values(@minStock, @supplier, @type, @stock, 0)
	select cast(@@IDENTITY as int)	
go

/********************************************************************************************
*****
*****
*********************************************************************************************/


if(OBJECT_ID('decreaseProductStock') is not null)
	DROP PROCEDURE decreaseProductStock
	
go

create procedure decreaseProductStock(@code int, @amount int)
as

	update Product set stock = stock - @amount where code = @code
go
